﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using mBlog.Services;
using System.Web.Mvc;
using mBlog.Data.Entities;

namespace mBlog.Core.Filters
{
    public class SpamCommentAttribute : CompressAttribute
    {
        public override void OnActionExecuting(System.Web.Mvc.ActionExecutingContext filterContext)
        {
            var comment = filterContext.ActionParameters["Comment"] as Comment;
            if (comment != null)
            {
                if (!SpamCommentService.CheckComment(comment))
                {
                    comment.IsSpam = true;

                    filterContext.ActionParameters["Comment"] = comment;
                }
            }
            base.OnActionExecuting(filterContext);
        }
    }
}
